/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */




var store = new Ext.data.JsonStore({
    url: "../../../servlet/data/YsjLoad",
    root: 'data',
    idProperty: 'id',
    totalProperty: 'count',
    fields: fieldName,
    autoLoad: true,
    baseParams: {lock:lock,cmd: loadCmd, start: 0, limit: _pageSize, dateFrom: now.format('Ym'), dateTo: now.format('Ym'), reportStatus: reportStatus,have:0}
});



var year = thisYear;
var month = thisMonth;

var yearToCombo = new tlf.component.YearCombo({
    value: thisYear,
    id: 'YearTo',
    listeners: {
        select: function(combo, record, index) {
            year = this.getValue();
            store.baseParams.dateFrom = year + month;
            store.baseParams.dateTo = year + month;
        }
    }
});

var monthToCombo = new tlf.component.MonthCombo({
    value: thisMonth,
    id: 'MonthTo',
    listeners: {
        select: function(combo, record, index) {
            month = this.getValue();
            store.baseParams.dateFrom = year + month;
            store.baseParams.dateTo = year + month;
        }
    }
});

var centergrid = new Ext.grid.GridPanel({
    title:currentOrgName + ' 合格率月统计报表',
    store: store,
    colModel: centercolumnModel,
    enableColumnMove: false,
    viewConfig: {
        forceFit: false
    },
    loadMask: true,
    tbar: new Ext.Toolbar([
        reportCombo,        
        rangeCombo,        
        pointTypeCombo,       
        pointType2Combo,
        voltageLevelCombo,
        pointText,                
        yearToCombo,
        {
            text: "年",
            xtype: 'label'
        },        
        monthToCombo,
        {
            text: "月",
            xtype: 'label'
        },
        '-',
        searchButton,
        '-',
        {
            xtype: 'button',
            text: '导出',
            iconCls: 'icon-excel',
            width: 60,
            style: {
                marginLeft: '20px'
            },
            handler: downloadExcel
        }
    ]),
    bbar: new Ext.PagingToolbar({
        pageSize: _pageSize,
        store: store,
        displayInfo: true,
        displayMsg: '显示记录：{0} - {1}   总记录：{2}',
        emptyMsg: '目前没有信息'
    })
});


function downloadExcel() {
    store.baseParams.type = 4;
    var encodeParams = Ext.urlEncode(store.baseParams);
    open('../../../servlet/common/ExcelFileCreate?' + encodeParams);
}

function buildWindow() {
    var applicationUI = new Ext.Viewport({
        layout: 'fit',
        items: [
            centergrid
        ]
    });
    if(reportStatus ===1){
        //Ext.getCmp('ReportStatus').setVisible(false);
        Ext.getCmp('ReportStatus').setValue(1);
    }
    
}
Ext.onReady(buildWindow); 